/******************************************************************************
 *
 * @file       main.cpp
 * @brief      线程池的使用；频繁创建和销毁线程惩罚你，让你的程序付出代价！
 *
 * @author     xiYan
 * @date       2025/06/07
 * @history
 *****************************************************************************/
#include <QCoreApplication>
#include <QThreadPool>
#include "counter.h"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QThread::currentThread()->setObjectName("Main");

    QThreadPool* pool = QThreadPool::globalInstance();
    // 线程不是越多越好
    qInfo() << pool->maxThreadCount() << "Threads";

    for(int i = 0; i< 100;++i)
    {
        Counter* c = new Counter();
        c->setAutoDelete(true);
        pool->start(c);
    }
    return a.exec();
}
